/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package loader;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Kiolvassa a config fájlból a pályára jellemző adatokat
 * @author pschmidt
 */
public class LoadFromConfigFile {

    private static final String filePath = "D:\\suli\\onlab\\AgentGame\\AgentGame.conf";
    /**
     * A pálya magassága négyzetekben mérve
     */
    private static int MapHeight;
    /**
     * A pálya szélessége négyzetekben mérve
     */
    private static int MapWidth;
    /**
     * Kezdő csapat erengia
     */
    private static int StartingEnergy;
    /**
     * Az ágens látótávolsága
     */
    private static int ViewDistance;
    /**
     * Egy támadás során hány mezővel löki arrébb az ellenfelet
     */
    private static int AttackPushEffect;
    /**
     * A támadás során az ellenefél mennyi energiát veszít ?! százalékban
     */
    private static int AttackedEnergyLoss;
    /**
     * Az energia átadás során mennyi energia veszik el ?! százalékban
     */
    private static int TransferEnergyLoss;
    /**
     * Fordulás energia költsége
     */
    private static int TurnCost;
    /**
     * Lépés energia költsége
     */
    private static int StepCost;
    /**
     * Támadás energia költsége
     */
    private static int AttackCost;
    /**
     * Pályán lévő ételek száma
     */
    private static int FoodCount;
    /**
     * Az étel minimum energia tartalma
     */
    private static int MinFoodValue;
    /**
     * Az étel maximum energia tartalma
     */
    private static int MaxFoodValue;
    /**
     * Az étel ennyi energiát veszít, amíg egyedül áll
     */
    private static int FoodValueLostAlone;
    /**
     * Az étel ennyi energiát veszít, ha egy ágens rajta áll
     */
    private static int FoodValueLostAgents;
    /**
     * Ennyi számítási ideje van a csapatnak, secben kifejezve
     */
    private static int MaxTeamTime;
    /**
     * Egy ágensnek maximum ennyi számítási ideje van körönként
     */
    private static int MaxAgentTime;
    /**
     * Ennyi összefüggő víz mező van a pályán
     */
    private static int WaterCount;
    /**
     * Megadja hogy hány százaléka víz a pályának
     */
    private static int WaterCoveragePercent;
    /**
     * ?!
     */
    private static int WaterFactor;
    /**
     * ?!
     */
    private static int WaterSideAspect;
    /**
     * Kör limit
     */
    private static int RoundLimit;
    /**
     * Egy evés alatt maximum ennyi ételt tud elfogyasztani az ágens
     */
    private static int MaxFoodEaten;
    /** It's show in the game a the map size regenerate is it enabled*/
    private static boolean MapResizeable = false;
    /** Minimum that so many round should pass until the first map resize */
    private static int MinMapRegenRound = 0;
    /** The difference between the minimum and the maximum turn for the regenerate */
    private static int MaxMapRegenRound = 0;
    /** Min map size after regenerate*/
    private static int MinMapSize = 0;
    /** Max map size after regenerate*/
    private static int MaxMapSize = 0;

    static {
        try {
            BufferedReader bf = new BufferedReader(new FileReader(filePath));
            String line;
            while ((line = bf.readLine()) != null) {
                if (line.startsWith("MapHeight")) {
                    MapHeight = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MapWidth")) {
                    MapWidth = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("StartingEnergy")) {
                    StartingEnergy = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("ViewDistance")) {
                    ViewDistance = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("AttackPushEffect")) {
                    AttackPushEffect = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("AttackedEnergyLoss")) {
                    AttackedEnergyLoss = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("TransferEnergyLoss")) {
                    TransferEnergyLoss = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("TurnCost")) {
                    TurnCost = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("StepCost")) {
                    StepCost = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("AttackCost")) {
                    AttackCost = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("FoodCount")) {
                    FoodCount = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MinFoodValue")) {
                    MinFoodValue = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MaxFoodValue")) {
                    MaxFoodValue = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("FoodValueLostAlone")) {
                    FoodValueLostAlone = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("FoodValueLostAgents")) {
                    FoodValueLostAgents = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("RoundLimit")) {
                    RoundLimit = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MaxTeamTime")) {
                    MaxTeamTime = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MaxAgentTime")) {
                    MaxAgentTime = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("WaterCount")) {
                    WaterCount = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("WaterCoveragePercent")) {
                    WaterCoveragePercent = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("WaterFactor")) {
                    WaterFactor = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("WaterSideAspect")) {
                    WaterSideAspect = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MaxFoodEaten")) {
                    MaxFoodEaten = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MapResizeable")) {
                    MapResizeable = (Integer.parseInt(line.substring(line.indexOf("=") + 2))==1)?true:false;
                } else if (line.startsWith("MinMapRegenRound")) {
                    MinMapRegenRound = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MaxMapRegenRound")) {
                    MaxMapRegenRound = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MinMapSize")) {
                    MinMapSize = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                } else if (line.startsWith("MaxMapSize")) {
                    MaxMapSize = Integer.parseInt(line.substring(line.indexOf("=") + 2));
                }


            }
        } catch (IOException ex) {
            Logger.getLogger(LoadFromConfigFile.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static int getMaxMapRegenRound() {
        return MaxMapRegenRound;
    }

    public static void setMaxMapRegenRound(int MaxMapRegenRound) {
        LoadFromConfigFile.MaxMapRegenRound = MaxMapRegenRound;
    }

    public static int getMapHeight() {
        return MapHeight;
    }

    public static int getMapWidth() {
        return MapWidth;
    }

    public static int getStartingEnergy() {
        return StartingEnergy;
    }

    public static int getViewDistance() {
        return ViewDistance;
    }

    public static int getAttackPushEffect() {
        return AttackPushEffect;
    }

    public static int getAttackedEnergyLoss() {
        return AttackedEnergyLoss;
    }

    public static int getTransferEnergyLoss() {
        return TransferEnergyLoss;
    }

    public static int getTurnCost() {
        return TurnCost;
    }

    public static int getStepCost() {
        return StepCost;
    }

    public static int getAttackCost() {
        return AttackCost;
    }

    public static int getFoodCount() {
        return FoodCount;
    }

    public static int getMinFoodValue() {
        return MinFoodValue;
    }

    public static int getMaxFoodValue() {
        return MaxFoodValue;
    }

    public static int getFoodValueLostAlone() {
        return FoodValueLostAlone;
    }

    public static int getFoodValueLostAgents() {
        return FoodValueLostAgents;
    }

    public static int getMaxTeamTime() {
        return MaxTeamTime;
    }

    public static int getMaxAgentTime() {
        return MaxAgentTime;
    }

    public static int getWaterCount() {
        return WaterCount;
    }

    public static int getWaterCoveragePercent() {
        return WaterCoveragePercent;
    }

    public static int getWaterFactor() {
        return WaterFactor;
    }

    public static int getWaterSideAspect() {
        return WaterSideAspect;
    }

    public static int getRoundLimit() {
        return RoundLimit;
    }

    public static int getMaxFoodEaten() {
        return MaxFoodEaten;
    }

    public static int getDiffInMinAndMaxRegen() {
        return MaxMapRegenRound;
    }

    public static void setDiffInMinAndMaxRegen(int DiffInMinAndMaxRegen) {
        LoadFromConfigFile.MaxMapRegenRound = DiffInMinAndMaxRegen;
    }

    public static boolean isMapResizeable() {
        return MapResizeable;
    }

    public static void setMapResizeable(boolean MapResizeable) {
        LoadFromConfigFile.MapResizeable = MapResizeable;
    }

    public static int getMaxMapSize() {
        return MaxMapSize;
    }

    public static void setMaxMapSize(int MaxMapSize) {
        LoadFromConfigFile.MaxMapSize = MaxMapSize;
    }

    public static int getMinMapRegenRound() {
        return MinMapRegenRound;
    }

    public static void setMinMapRegenRound(int MinMapRegenRound) {
        LoadFromConfigFile.MinMapRegenRound = MinMapRegenRound;
    }

    public static int getMinMapSize() {
        return MinMapSize;
    }

    public static void setMinMapSize(int MinMapSize) {
        LoadFromConfigFile.MinMapSize = MinMapSize;
    }

    /**
     * Visszaadja az osztály változóinak értékét
     * @return 
     */
    public static String toStrings() {
        return "LoadFromConfigFile{" + "MapHeight=" + MapHeight + ", MapWidth=" + MapWidth + ", StartingEnergy=" + StartingEnergy + ", ViewDistance=" + ViewDistance + ", AttackPushEffect=" + AttackPushEffect + ", AttackedEnergyLoss=" + AttackedEnergyLoss + ", TransferEnergyLoss=" + TransferEnergyLoss + ", TurnCost=" + TurnCost + ", StepCost=" + StepCost + ", AttackCost=" + AttackCost + ", FoodCount=" + FoodCount + ", MinFoodValue=" + MinFoodValue + ", MaxFoodValue=" + MaxFoodValue + ", FoodValueLostAlone=" + FoodValueLostAlone + ", FoodValueLostAgents=" + FoodValueLostAgents + ", MaxTeamTime=" + MaxTeamTime + ", MaxAgentTime=" + MaxAgentTime + ", WaterCount=" + WaterCount + ", WaterCoveragePercent=" + WaterCoveragePercent + ", WaterFactor=" + WaterFactor + ", WaterSideAspect=" + WaterSideAspect + ", RoundLimit=" + RoundLimit + '}';
    }
}
